<template>
    <div style="padding: 10px;">
        <el-form :model="formData" ref="queryForm" :inline="true" :rules="Rules" label-width="auto"
                 @submit.native.prevent>
            <el-form-item label="表格名称" desc="" prop="tableName">
                <el-input v-model.trim="formData.tableName" placeholder="" clearable size="small"
                          style="width:120px;" />
            </el-form-item>
            <el-form-item label="表格中文" desc="" prop="tableNameChinese">
                <el-input v-model.trim="formData.tableNameChinese" placeholder="" clearable size="small"
                          style="width:120px;" />
            </el-form-item>
        </el-form>
    </div>
</template>
<script>  import { getUrlParam } from '@/utils/index';
import { alertWithPaylod } from '@/utils/alertUtil';
import * as  api from '@/apis/gTable.api.js';
import { default as FormDialog } from '@codegenarate/mydialogplus';
import { fillData, validatePromise } from '@/utils/index';

const Rules = {
  'id': [{ required: false, message: '', trigger: 'blur' }],
  'tableName': [{ required: true, message: '', trigger: 'blur' }],
  'tableNameChinese': [{ required: true, message: '', trigger: 'blur' }],
  'delState': [{ required: false, message: '', trigger: 'blur' }],
};
const dicInner = {
  '___g_table_id': '',
  'g_table_id': 'g_table_id',
  '___g_table_tableName': '',
  'g_table_tableName': 'g_table_tableName',
  '___g_table_tableNameChinese': '',
  'g_table_tableNameChinese': 'g_table_tableNameChinese',
  '___g_table_delState': '',
  'g_table_delState': 'g_table_delState',
};
export default {
  name: 'gTableModify',
  data() {
    return {
      api: api,
      Rules,
      dicInner,
      formData: { 'id': '', 'tableName': '', 'tableNameChinese': '', 'delState': '' },
      lists: [],
      selectRows: [],
      classId: '',
      classIdPath: '',
      className: '',
      loading: false,
      isFold: false,
      tableRowClassName({ row, rowIndex }) {
        if (row.rowType == 'total') {
          return 'total-row';
        }
        return '';
      },
    };
  },
  components: {
    svgIcon: () => import('@codegenarate/svg-icon'),
    dicSelect: () => import('@/components/dicselect.vue'),
    dicTag: () => import('@/components/DicSelect/dic-tag.vue'),
  },
  computed: {},
  watch: {},
  methods: {
    /**       *  @params _data.         * @desc 初始化        */      initByDialog(_data) {
      fillData(this.formData, _data);
      console.log('初始化数据', this.formData);
    }, async submitByDialog(_data) {
      var isyes = await validatePromise.call(this, 'queryForm');
      if (!isyes) {
        return { success: false, message: '请检查必填项' };
      }
      var func = this.formData.id ? api.update : api.add;
      var result = await func(this.formData);
      alertWithPaylod(result);
      return result;
    },
  },
};</script>
